Valid for Sitecore
5.3.1
4.
Date and DateTime
Prev Next |
The complex field type, Date or DateTime stores it values as raw text, for example:
20051003T120000 or 20051003T163256
Resolve the value by using implicit casting
// Date, DateTime
public static string outDate_DateTime(Sitecore.Data.Items.Item item, string sFieldName)
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
Sitecore.Data.Fields.DateField dateField = item.Fields[sFieldName];
builder.Append(dateField.DateTime.ToString("dddd, d. MMM. yyyy (hh:mm:ss)"));
builder.Append("<br />");
return builder.ToString();
}
Result (Danish localized settings):
mandag, 3. okt. 2005 (12:00:00)
or
mandag, 3. okt. 2005 (04:32:56)
Prev Next